<?php

namespace app\models\Child;

use Yii;

/**
 * This is the model class for table "init_advert".
 *
 * @property integer $ad_id
 * @property string $ad_name
 * @property string $ad_image
 * @property integer $ad_index
 * @property string $skip_url
 * @property integer $ad_status
 * @property string $ad_start_time
 * @property string $ad_end_time
 * @property integer $create_user_id
 * @property string $create_time
 */
class InitAdvert extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'init_advert';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['ad_index', 'ad_status', 'create_user_id'], 'integer'],
            [['ad_start_time', 'ad_end_time', 'create_time'], 'safe'],
            [['ad_name'], 'string', 'max' => 40],
            [['ad_image', 'skip_url'], 'string', 'max' => 200],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ad_id' => 'Ad ID',
            'ad_name' => 'Ad Name',
            'ad_image' => 'Ad Image',
            'ad_index' => 'Ad Index',
            'skip_url' => 'Skip Url',
            'ad_status' => 'Ad Status',
            'ad_start_time' => 'Ad Start Time',
            'ad_end_time' => 'Ad End Time',
            'create_user_id' => 'Create User ID',
            'create_time' => 'Create Time',
        ];
    }
    /*
     * 查询各分店轮播图和广播
     */
    public function getAdvertList($subclinic_id,$ad_type)
    {
        $list = $this->find()
                ->where(['subclinic_id' => $subclinic_id,'ad_type' => $ad_type])
                ->asArray()
                ->all();
        return $list;
    }
}
